package io.zerous.engine

import android.content.Context
import android.content.SharedPreferences
import android.os.Environment
import android.preference.PreferenceManager
import java.io.File
import java.io.FileInputStream
import java.io.InputStream

/**
 * Created by Zerous on 2018/3/20.
 */
class FileIO(context: Context) {
    val externalStoragePath = Environment.getExternalStorageDirectory().absolutePath + File.separator
    val ctx = context

    fun readAsset(fileName: String): InputStream {
        return ctx.assets.open(fileName)
    }

    fun readFile(fileName: String): InputStream {
        return FileInputStream(externalStoragePath + fileName)
    }

    fun getPreferences(): SharedPreferences {
        return PreferenceManager.getDefaultSharedPreferences(ctx)
    }
}